<%@ page import="com.ws.q1.conifg.Res" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户中心</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: Arial, sans-serif;
        }

        .user-center {
            background: #f5f5f5;
            padding: 20px;
        }

        .header-section {
            background: #007bff;
            color: white;
            padding: 30px;
            border-radius: 8px;
            margin-bottom: 20px;
        }

        .user-info {
            display: flex;
            align-items: center;
        }

        .user-avatar {
            width: 60px;
            height: 60px;
            border-radius: 50%;
            background: #fff;
            margin-right: 20px;
        }

        .user-name {
            font-size: 24px;
            margin-bottom: 8px;
        }

        .user-detail {
            margin-top: 8px;
        }

        .tab-section {
            background: white;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
        }

        .tab-buttons {
            display: flex;
            border-bottom: 2px solid #007bff;
        }

        .tab-btn {
            padding: 10px 20px;
            margin-right: 20px;
            cursor: pointer;
            color: #333;
            border-bottom: 2px solid transparent;
        }

        .tab-btn.active {
            color: #007bff;
            border-bottom: 2px solid #007bff;
        }

        .content-section {
            display: none;
        }

        .content-section.active {
            display: block;
        }

        .collection-item {
            border: 1px solid #eee;
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 15px;
        }

        .item-price {
            color: #666;
            font-size: 14px;
            margin: 8px 0;
        }

        .item-ops a {
            color: #007bff;
            text-decoration: none;
            margin-right: 10px;
        }
    </style>
</head>
<body>
<div class="user-center">
    <div class="header-section">
        <div class="user-info">
            <img class="user-avatar" src="<%=Res.fileUrl%>${user.tou}" width="50" height="50" alt="用户头像">
            <div>
                <div class="user-name">欢迎： ${user.name}</div>
                <div class="user-detail">
                    <span>手机号：${user.phone}</span>
                </div>
            </div>
<%--            <a href="${pageContext.request.contextPath}/denglu/updater" class="btn btn-primary">修改信息</a>--%>
            <a href="${pageContext.request.contextPath}/hui/huixian?id=${user.id}" class="btn btn-primary">修改</a>
        </div>
        <a href="${pageContext.request.contextPath}/qiantai/index" class="btn btn-primary">回到首页</a>
    </div>

    <div class="tab-section">
        <div class="tab-buttons">
            <span class="tab-btn" data-tab="orders" onclick="showTab(this)">我的订单</span>
            <span class="tab-btn active" data-tab="collections" onclick="showTab(this)">我的收藏</span>
        </div>
    </div>

    <div id="orders" class="content-section">
        <h3>我的订单</h3>
        <div class="collection-item">
            <img src="travel-icon.png" alt="旅游项目" style="width: 30px; height: 30px; margin-right: 10px;">
            <div>
                <h4>丽江古城深度游</h4>
                <div class="item-price">¥1280 起</div>
                <div class="item-ops">
                    <a href="#">查看详情</a>
                    <a href="#">取消订单</a>
                </div>
            </div>
        </div>
    </div>

    <div id="collections" class="content-section active">
        <h3>我的收藏</h3>
        <div class="collection-item">
            <img src="travel-icon.png" alt="旅游项目" style="width: 30px; height: 30px; margin-right: 10px;">
            <div>
                <h4>丽江古城深度游</h4>
                <div class="item-price">¥1280 起</div>
                <div class="item-ops">
                    <a href="#">查看详情</a>
                    <a href="#">取消收藏</a>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    function showTab(button) {
        console.log('showTab called with button:', button); // 调试信息

        // 获取所有tab按钮并移除active类
        const tabButtons = document.querySelectorAll('.tab-btn');
        tabButtons.forEach(btn => btn.classList.remove('active'));

        // 获取所有内容区域并移除active类
        const contentSections = document.querySelectorAll('.content-section');
        contentSections.forEach(section => section.classList.remove('active'));

        // 添加active类到点击的tab按钮
        button.classList.add('active');

        // 获取tabId
        const tabId = button.getAttribute('data-tab');

        // 显示对应的内容区域
        document.getElementById(tabId).classList.add('active');
    }

    // 初始化时确保默认标签被激活
    document.addEventListener('DOMContentLoaded', function() {
        const activeTabButton = document.querySelector('.tab-btn.active');
        if (activeTabButton) {
            showTab(activeTabButton);
        }
    });
</script>
</body>
</html>
